﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Mail;

namespace e_commerce.BLL.Util
{
    public class Mei_Mail
    {
        public int SendMailLocalhost(string sender)
        {
            Random rnd = new Random();
            int code = rnd.Next(1000, 9999);
            MailMessage msg = new MailMessage();
            msg.To.Add(sender);
            msg.From = new MailAddress("15923123802@163.com", "魅商官方邮件", System.Text.Encoding.UTF8);
            msg.Subject = "注册邮件";
            msg.SubjectEncoding = System.Text.Encoding.UTF8;
            msg.Body = code.ToString();
            msg.BodyEncoding = System.Text.Encoding.UTF8;
            msg.IsBodyHtml = false;
            msg.Priority = MailPriority.High;

            SmtpClient client = new SmtpClient();
            client.UseDefaultCredentials = true;
            client.Credentials = new System.Net.NetworkCredential("15923123802@163.com", "zqq20170101");
            client.Host = "smtp.163.com";
            client.Port = 25;
            client.EnableSsl = true;
            client.Send(msg);
            return code;
        }
    }
}
